/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hessingerbg.codebehind;

import java.awt.Robot;

/**
 * @author MikeLaptop
 */
public class movementroutine implements subroutine {

    private movementmanager move;
    private movementthread movethread;
    private movement next;
    private long lastQueue = 0;

    public movementroutine()
    {
        try {
            log.println("Initializing Movement and Queueing Routines");
            move = movementmanager.readFile();
            next = move.elementAt(0);
            movethread = new movementthread(next);

        } catch (Exception ex) {
           // log.println(ex);
        }
    }

    public void doRoutine() {
        //if(!movethread.isRunning())
        //{
            movethread.run();
        //}

        log.println("Accepting battleground queue");
        movethread.AcceptQueue();

        if((System.currentTimeMillis() - lastQueue) > 50000)
        {
            log.println("Queueing battlegrounds");
            lastQueue = System.currentTimeMillis();
            movethread.Queue();
        }
    }

    public boolean requiresStop() {
        return false;
    }

    public void fullStop() {
        log.println("Stopping all movements");
        movethread.Stop();
    }

    public void useSpell() {
        return;
    }
}
